package sat.component;

import org.mt4j.MTApplication;
import org.mt4j.components.visibleComponents.widgets.keyboard.MTKeyboard;
import org.mt4j.util.MTColor;
import org.mt4j.util.math.Vector3D;

public class Keyboard extends MTKeyboard{
	private MTApplication app;
	private KeyboardTextField.type mode;	//different type of keyboard
	private KeyboardTabArray tabList;	//keywords for keyboard mode=1

	private KeyboardTabArrayImage tabListImage;	//key-relations for keyboard mode=2,3
	public KeyboardTextField m_textField;
	
	public KeyboardTextField getTextField() {
		return m_textField;
	}

	static final float tbHeight = 245; //height of keyboard
	static final float tbWidth = 700; //height of keyboard
	
	public KeyboardTabArray getTabArray(){
		return tabList;
	}
	
	public KeyboardTabArrayImage getTabArrayImage(){
		return tabListImage;
	}
	
	public Keyboard(MTApplication mtApplication, KeyboardTextField.type m, KeyboardTextField textField) {
		super(mtApplication);
		
		app=mtApplication;
		mode=m;
		m_textField = textField;
		this.setFillColor(new MTColor(30, 30, 30, 210));
		this.setStrokeColor(new MTColor(0,0,0,255));

		this.setPositionGlobal(new Vector3D((app.width)/2,(app.height)/2,20));
	
		// different mode of keyboard
		
		// mode = 0 normal
		if(this.mode== KeyboardTextField.type.nomral)
			this.setPositionGlobal(new Vector3D(mtApplication.width/2f, mtApplication.height/2f,0));
		
		//mode=1 for class diagram class
		if(this.mode==KeyboardTextField.type.classes)
		{
			tabList = new KeyboardTabArray(this.app,this);
			this.addChild(tabList);
			
			// set the tab list position
			tabList.setPositionRelativeToParent(
					new Vector3D(
							KeyboardTabArray.tabListWidth/2+30,
							-KeyboardTabArray.tabListHeight/2
							)
					);
			
//			this.setPositionRelativeToParent(new Vector3D(app.width/2,app.height-tbHeight/2));
			
		}
		
		//mode=2 for class diagram relation
		if(mode==KeyboardTextField.type.links)
		{
			tabListImage = new KeyboardTabArrayImage(this.app,this,2);
			this.addChild(tabListImage);
			
			tabListImage.setPositionRelativeToParent(
					new Vector3D(
							KeyboardTabArray.tabListWidth/2+30,
							-KeyboardTabArray.tabListHeight/2
							)
					);
//			this.setPositionRelativeToParent(new Vector3D(app.width/2,app.height-tbHeight/2));
			
		}
		//mode=3 for use case diagram
		if(mode==KeyboardTextField.type.useCase)
		{
			/*tabListImage = new KeyboardTabArrayImage(this.app,this,tabListWidth,tabListHeight,3);
			this.addChild(tabListImage);
			
			tabListImage.setPositionRelativeToParent(
					new Vector3D(
							this.getCenterPointRelativeToParent().x,
							this.getCenterPointRelativeToParent().y-tbHeight/2-tabListImage.getHeightXY(TransformSpace.RELATIVE_TO_PARENT)/2
							)
					);
			//TODO
			this.setPositionRelativeToParent(new Vector3D(app.width/2,app.height-tbHeight/2));*/
		}
	}
}
